DB server side improved some problems when showing bookings remain
[RRRRHHHH_Code] / ruralHouses client / src / gui / listOfBookingRequestsGUI.java
index ba96f0d..aab2736 100644 (file)
@@ -62,10 +62,8 @@ public class listOfBookingRequestsGUI extends JFrame {
                setContentPane(contentPane);
                contentPane.setLayout(null);
 
-               BookingInterface bm = null;
-               
                try {
-                       bm = (BookingInterface) Naming
+                       bookM = (BookingInterface) Naming
                                        .lookup(___IntNames.BookingManager);
 
                } catch (Exception e1) {
@@ -73,11 +71,11 @@ public class listOfBookingRequestsGUI extends JFrame {
                                        + e1.toString());
                }
                try {
-                       this.bookings = bm.getOffersbookings(this.off);
+                       this.bookings = bookM.getOffersbookings(this.off);
                } catch (RemoteException e1) {
                        e1.printStackTrace();
                }
-               
+
                JLabel lblNewLabel = new JLabel();
                lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 27));
                lblNewLabel.setBounds(23, 41, 536, 33);
@@ -101,17 +99,11 @@ public class listOfBookingRequestsGUI extends JFrame {
 
                table.setModel(tableModel);
 
+               JButton btnDenyAddition = new JButton("Deny Booking");
                JButton btnNewButton = new JButton("Confirm Booking");
                btnNewButton.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
-                               try {
-                                       bookM = (BookingInterface) Naming
-                                                       .lookup(___IntNames.BookingManager);
-                               } catch (Exception e1) {
-                                       System.out
-                                                       .println("Error accessing remote authentication: "
-                                                                       + e1.toString());
-                               }
+
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        if (table.getRowCount() != 0
                                                        && table.getSelectedRow() != -1) {
@@ -121,8 +113,19 @@ public class listOfBookingRequestsGUI extends JFrame {
                                                } catch (RemoteException e1) {
                                                        e1.printStackTrace();
                                                }
-                                               contentPane.setVisible(false);
-
+                                               int rows = table.getModel().getRowCount(); 
+                                               for(int i = rows - 1; i >=0; i--){
+                                                       ((DefaultTableModel) table.getModel()).removeRow(i);
+                                               }
+                                               Vector<Object> row = new Vector<Object>();
+                                               row.add(book.getBookNumber());
+                                               row.add(book.getBookDate());
+                                               row.add(book.getClient().getName());
+                                               row.add(book.getClient().getMailAccount());
+                                               row.add(book.getClient().getTelephone());
+                                               tableModel.addRow(row);
+                                               btnNewButton.setEnabled(false);
+                                               btnDenyAddition.setEnabled(false);
                                        }
 
                                }
@@ -131,17 +134,9 @@ public class listOfBookingRequestsGUI extends JFrame {
                btnNewButton.setBounds(33, 396, 169, 25);
                contentPane.add(btnNewButton);
 
-               JButton btnDenyAddition = new JButton("Deny Booking");
                btnDenyAddition.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent arg0) {
-                               try {
-                                       bookM = (BookingInterface) Naming
-                                                       .lookup(___IntNames.BookingManager);
-                               } catch (Exception e1) {
-                                       System.out
-                                                       .println("Error accessing remote authentication: "
-                                                                       + e1.toString());
-                               }
+
                                if (table.getRowCount() != 0 && table.getSelectedRow() != -1) {
                                        Booking book = bookings.get(table.getSelectedRow());
                                        try {
@@ -166,7 +161,7 @@ public class listOfBookingRequestsGUI extends JFrame {
                                btnNewButton.setEnabled(false);
                        }
                }
-               
+
                btnDenyAddition.setBounds(390, 395, 169, 25);
                contentPane.add(btnDenyAddition);